package com.swsc.solarverse.common.util;

/**
 * @Author chencl
 * @Date 2024/5/16 17:14
 * @Version 1.0
 * @Description
 */
public class DefectHelper {
    public static String parseLeFault(Double actualLowI, Double actualLowU, double lowIThreshold, double lowUThreshold) {
        String faultReason = null;
        if (null != actualLowI && null != actualLowU && actualLowI > lowIThreshold && actualLowU > 0) {
            faultReason = "电流电压低效";
        }
        if (null != actualLowI) {
            if (null != actualLowU) {
                if (actualLowI > lowIThreshold && actualLowU > lowUThreshold) {
                    faultReason = "电流电压低效";
                } else if (actualLowI > lowIThreshold) {
                    faultReason = "电流低效";
                } else if (actualLowU > lowUThreshold) {
                    faultReason = "电压低效";
                }
            } else {
                if (actualLowI > lowIThreshold) {
                    faultReason = "电流低效";
                }
            }
        } else {
            if (null != actualLowU) {
                if (actualLowU > lowUThreshold) {
                    faultReason = "电压低效";
                }
            }
        }
        return faultReason;
    }

    private DefectHelper() {
    }

    public static String escapeSpecificCharacters(String url) {
        if (null != url && !"".equals(url)) {
            // 替换空格为 %20
            url = url.replace(" ", "%20");
            // 替换 # 为 %23
            url = url.replace("#", "%23");
            // 替换 $ 为 %24
            url = url.replace("$", "%24");
        }
        return url;
    }
}
